package nsqproducer

import (
	"github.com/nsqio/go-nsq"
	"sync"
	"time"
)

type PushNode struct {
	nsqdCountNum         int
	nsqdFristProducerNum int
	nsqdNowProducerNum   int
	nextNodeIndex        int
	ConnNodeDepth        chan struct{}
	NsqdProducerMaxNum   int
	Topic                string
	nodeIndexLock        *sync.Mutex
	NsqConf              *nsq.Config
	CheckInterval        time.Duration
	RetryPushInterval    time.Duration
	RetryPushMaxNum      int
	RetryNodeDepth       int
	nodes                NsqdNodes
	nodesTemp            NsqdNodes
	nsqdTempProducerNum  int
	nodeList             sync.Map
}

type NodeIndex struct {
	Index  int
	Status bool
}

type NsqdNodes struct {
	Producers []NsqdNode `json:"producers"`
}

type NsqdNode struct {
	RemoteAddress    string   `json:"remote_address"`
	HostName         string   `json:"hostname"`
	BroadcastAddress string   `json:"broadcast_address"`
	TcpPort          int      `json:"tcp_port"`
	HttpPort         int      `json:"http_port"`
	Version          string   `json:"version"`
	Tombstones       []bool   `json:"tombstones"`
	Topics           []string `json:"topics"`
	nsqdStatus       bool
	producer         *nsq.Producer
	nsqdAddr         string
}

var welcome = `
 /~~~~~~~~\_/~~~~~~~\__/~~~~~~~\__/~~\__/~~\_
 ___/~~\____/~~\__/~~\_/~~\__/~~\_/~~\__/~~\_
 ___/~~\____/~~\__/~~\_/~~\__/~~\_/~~~~~~~~\_
 ___/~~\____/~~\__/~~\_/~~\__/~~\_/~~\__/~~\_
 ___/~~\____/~~~~~~~\__/~~~~~~~\__/~~\__/~~\_`
